@import '../../style/themes/index';
@import '../../style/mixins/index';
@import '../../input/style/mixin';

@timepicker-prefix-cls :~'@{vcu-prefix}-time-picker';
@timepicker-item-height: 32px;

.@{timepicker-prefix-cls}-panel {
  .reset-component;

  position   : absolute;
  z-index    : @zindex-picker;
  font-family: @font-family;

  &-inner {
    position        : relative;
    left            : -2px;
    font-size       : @font-size-base;
    text-align      : left;
    list-style      : none;
    background-color: @component-background;
    background-clip : padding-box;
    border-radius   : @border-radius-base;
    outline         : none;
    box-shadow      : @box-shadow-base;
  }

  &-input {
    width      : 100%;
    max-width  : @time-picker-panel-column-width * 3 - @control-padding-horizontal - 2px;
    margin     : 0;
    padding    : 0;
    line-height: normal;
    border     : 0;
    outline    : 0;
    cursor     : auto;

    .placeholder;

    &-wrap {
      position     : relative;
      padding      : 7px 2px 7px @control-padding-horizontal;
      border-bottom: @border-width-base @border-style-base @border-color-split;
    }

    &-invalid {
      border-color: @error-color;
    }
  }

  &-narrow &-input-wrap {
    max-width: @time-picker-panel-column-width * 2;
  }

  &-select {
    position   : relative; // Fix chrome weird render bug
    float      : left;
    width      : @time-picker-panel-column-width;
    max-height : @timepicker-item-height * 6;
    overflow   : hidden;
    font-size  : @font-size-base;
    border-left: @border-width-base @border-style-base @border-color-split;

    &:hover {
      overflow-y: auto;
    }

    &:first-child {
      margin-left: 0;
      border-left: 0;
    }

    &:last-child {
      border-right: 0;
    }

    &:only-child {
      width: 100%;
    }

    ul {
      // use fixed width instead of 100%
      width     : @time-picker-panel-column-width;
      margin    : 0;
      padding   : 0 0 @timepicker-item-height * 5;
      list-style: none;
    }

    li {
      width      : 100%;
      height     : @timepicker-item-height;
      margin     : 0;
      padding    : 0 0 0 @control-padding-horizontal;
      line-height: @timepicker-item-height;
      text-align : left;
      list-style : none;
      cursor     : pointer;
      transition : all 0.3s;
      user-select: none;

      &:focus {
        color      : @primary-color;
        font-weight: 600;
        outline    : none;
      }
    }

    li:hover {
      background: @item-hover-bg;
    }

    li&-option-selected {
      font-weight: 600;
      background : @time-picker-selected-bg;

      &:hover {
        background: @time-picker-selected-bg;
      }
    }

    li&-option-disabled {
      color: @btn-disable-color;

      &:hover {
        background: transparent;
        cursor    : not-allowed;
      }

      &:focus {
        color      : @btn-disable-color;
        font-weight: inherit;
      }
    }
  }

  &-combobox {
    .clearfix;
  }

  &-addon {
    padding   : 8px;
    border-top: @border-width-base @border-style-base @border-color-split;
  }

  &.slide-up-enter.slide-up-enter-active&-placement-topLeft,
  &.slide-up-enter.slide-up-enter-active&-placement-topRight,
  &.slide-up-appear.slide-up-appear-active&-placement-topLeft,
  &.slide-up-appear.slide-up-appear-active&-placement-topRight {
    animation-name: vcuSlideDownIn;
  }

  &.slide-up-enter.slide-up-enter-active&-placement-bottomLeft,
  &.slide-up-enter.slide-up-enter-active&-placement-bottomRight,
  &.slide-up-appear.slide-up-appear-active&-placement-bottomLeft,
  &.slide-up-appear.slide-up-appear-active&-placement-bottomRight {
    animation-name: vcuSlideUpIn;
  }

  &.slide-up-leave.slide-up-leave-active&-placement-topLeft,
  &.slide-up-leave.slide-up-leave-active&-placement-topRight {
    animation-name: vcuSlideDownOut;
  }

  &.slide-up-leave.slide-up-leave-active&-placement-bottomLeft,
  &.slide-up-leave.slide-up-leave-active&-placement-bottomRight {
    animation-name: vcuSlideUpOut;
  }
}

.@{timepicker-prefix-cls} {
  .reset-component;

  position  : relative;
  display   : inline-block;
  width     : 128px;
  outline   : none;
  cursor    : text;
  transition: opacity 0.3s;

  &-input {
    .input;

    &[disabled] {
      .disabled;
    }
  }

  &-open {
    opacity: 0;
  }

  &-icon,
  &-clear {
    position   : absolute;
    top        : 50%;
    right      : @control-padding-horizontal - 5;
    z-index    : 1;
    width      : 14px;
    height     : 14px;
    margin-top : -7px;
    color      : @disabled-color;
    line-height: 14px;
    transition : all 0.3s @ease-in-out;
    user-select: none;

    .@{timepicker-prefix-cls}-clock-icon {
      display    : block;
      color      : @disabled-color;
      line-height: 1;
    }
  }

  &-clear {
    z-index       : 2;
    background    : @input-bg;
    opacity       : 0;
    pointer-events: none;

    &:hover {
      color: @text-color-secondary;
    }
  }

  &:hover &-clear {
    opacity       : 1;
    pointer-events: auto;
  }

  &-large &-input {
    .input-lg;
  }

  &-small &-input {
    .input-sm;
  }

  &-mini &-input {
    .input-mini;
  }

  &-small &-icon,
  &-small &-clear {
    right: @control-padding-horizontal-sm - 1px;
  }

  &-mini &-icon,
  &-mini &-clear {
    font-size: @font-size-mini;
    top      : 60%;
    right    : @control-padding-horizontal-mini - 2px;
  }
}

// Fix cursor height in safari
// https://stackoverflow.com/q/3843408/3040605
// https://browserstrangeness.github.io/css_hacks.html#safari
@media not all and (min-resolution: 0.001dpcm) {
  @supports (-webkit-appearance: none) and (stroke-color: transparent) {
    .@{vcu-prefix}-input {
      line-height: @line-height-base;
    }
  }
}